package com.putao.album.dialog;

import android.content.Context;

import static com.putao.album.dialog.DialogBuilderFactory.DialogType.CONFIRM;

/**
 * Created by jidongdong on 15/5/6.
 */
public class DialogBuilderFactory<T extends DialogBuilder> {

    private DialogType mType = CONFIRM;
    private Context mContext;

    public DialogBuilderFactory(Context context, DialogType type) {
        mContext = context;
        mType = type;
    }

    public DialogBuilderFactory(Context context) {
        this(context, CONFIRM);
    }

    @SuppressWarnings("unchecked")
    public T Builder() {
        T t = null;
        switch (mType) {
            case CONFIRM:
                t = (T) new ConfirmDialogBuilder(mContext);
                break;
            case IMPORT:
                t = (T) new ImportDialogBuilder(mContext);
                break;
            case LOADING:
                t = (T) new LoadingDialogBuilder(mContext);
                break;
            case SELECT:
                t = (T) new SelectDialogBuilder(mContext);
                break;
            case MESSAGE:
                t = (T) new MessageDialogBuilder(mContext);
                break;
            case SHAREAPP:
                t = (T) new ShareAppDialogBuilder(mContext);
                break;
            default:
                break;
        }
        return t;
    }

    public enum DialogType {
        CONFIRM,
        IMPORT,
        LOADING,
        SELECT,
        MESSAGE,
        SHAREAPP
    }

}
